package com.moli.iov.his.aspect;

import lombok.extern.slf4j.Slf4j;
import org.aspectj.lang.JoinPoint;
import org.springframework.stereotype.Component;

import java.util.Arrays;

/**
 * @ClassName LogAspect
 * @Description TODO
 * @Author 李伟松
 * @CreateDate 2019-09-09 下午 3:31
 * @UpdateDate 2019-09-09 下午 3:31
 * @Version 1.0
 */
@Component
@Slf4j
public class LogAspect {
    public void beforeMethod(JoinPoint joinPoint) {
        String methodName = joinPoint.getSignature().getName();
        Object[] args = joinPoint.getArgs();
        long times = System.currentTimeMillis();
        System.out.println("start execute time:" + times + "," + methodName + " start execute,args:" + Arrays.toString(args));
    }

    public void afterMethod(JoinPoint joinPoint) {
        String methodName = joinPoint.getSignature().getName();
        long times = System.currentTimeMillis();
        System.out.println("after execute time:" + times + "," + methodName + " execute end");
    }

//    public void afterReturning(JoinPoint joinPoint, Object result) {
//        String methodName = joinPoint.getSignature().getName();
//        System.out.println(methodName + " execute result:" + result);
//    }
//
//    public void afterThrowing(JoinPoint joinPoint, Exception e) {
//        String methodName = joinPoint.getSignature().getName();
//        System.out.println(methodName + " execute exception:" + e);
//    }
}
